<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="referrer" content="no-referrer" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>后台登录</title>
  <link rel="shortcut icon" href="favicon.ico">
  <!-- 引入样式 -->
  <link rel="stylesheet" href="/static/plugins/element-ui/index.css" />
  <link rel="stylesheet" href="/static/styles/common.css">
  <link rel="stylesheet" href="/static/styles/login.css">
  <link rel="stylesheet" href="/static/styles/icon/iconfont.css" />
  <style>
    .body{
      min-width: 1366px;
    }
  </style>
</head> 

<body>
  <div class="login" id="login-app">
    <div class="login-box">
      <img src="/static/image/img4.png" alt="">
      <div class="login-form">
        <el-form ref="loginForm" :model="loginForm" :rules="loginRules">
          <div class="login-form-title">
            <img src="/static/image/img.png" style="width:139px;height:42px;" alt="" />
          </div>
          <form method="post" action="/order/login">
            用户名：<input type="text" name="username" >
            <div style="color: red" v-if="errorContent==1">用户名或密码错误</div>
            <br>
            密码：<input type="password" name="password" ><br>
            <input type="checkbox" name="remember-me" style="font-size: small">自动登录（7天）<br>
            <input type="submit" class="login-btn" size="medium" type="primary" style="width:100%;" value="登录">
          </form>
<!--          <el-form-item prop="username">-->
<!--            <el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号" maxlength="20"-->
<!--              prefix-icon="iconfont icon-user" />-->
<!--          </el-form-item>-->
<!--          <el-form-item prop="password">-->
<!--            <el-input v-model="loginForm.password" type="password" placeholder="密码" prefix-icon="iconfont icon-lock" maxlength="20"-->
<!--              />-->
<!--          </el-form-item>-->
<!--          <el-form-item style="width:100%;">-->
<!--            <el-button :loading="loading" class="login-btn" size="medium" type="primary" style="width:100%;"-->
<!--              @click="handleLogin">-->
<!--              <span v-if="!loading">登录</span>-->
<!--              <span v-else>登录中...</span>-->
<!--            </el-button>-->
<!--          </el-form-item>-->
        </el-form>
      </div>
    </div>
  </div>

  <!-- 开发环境版本，包含了有帮助的命令行警告 -->
  <script src="/static/plugins/vue/vue.js"></script>
  <!-- 引入组件库 -->
  <script src="/static/plugins/element-ui/index.js"></script>
  <!-- 引入axios -->
  <script src="/static/plugins/axios/axios.min.js"></script>
<!--  <script src="js/request.js"></script>-->
<!--  <script src="js/validate.js"></script>-->
<!--  <script src="api/login.js"></script>-->

  <script>
    new Vue({
      el: '#login-app',
      data() {
        return {
          loginForm:{
            username: 'root',
            password: '123'
          },
          loading: false,
          errorContent:""
        }
      },
      computed: {
        loginRules() {
          const validateUsername = (rule, value, callback) => {
            if (value.length < 1 ) {
              callback(new Error('请输入用户名'))
            } else {
              callback()
            }
          }
          const validatePassword = (rule, value, callback) => {
            if (value.length < 3) {
              callback(new Error('密码必须在3位以上'))
            } else {
              callback()
            }
          }
          return {
            'username': [{ 'validator': validateUsername, 'trigger': 'blur' }],
            'password': [{ 'validator': validatePassword, 'trigger': 'blur' }]
          }
        }
      },
      created() {
        this.getUrl();
      },
      methods: {
        getUrl(){
          var url = decodeURIComponent(location.search);
          var theRequest = new Object();
          if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            var strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
              theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
            }
          }
          this.errorContent=theRequest.name;
        },
        handleLogin(){
              axios.post("/order/login",{
                params: {
                  username: this.loginForm.username,
                  password: this.loginForm.password
                }
              })
            }
          }
        })
  </script>
</body>

</html>
